package com.audaque.springboot.foshanupload.core.util;

import lombok.extern.slf4j.Slf4j;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author zgb
 * @desc ...
 * @date 2023-03-02 10:42:20
 */
@Slf4j
public class DateFormatUtil {

    public static final String TIME_HOUSER_FORMAT = "HH:mm";
    public static final String TIME_DEFAULT_FORMAT = "HH:mm:ss";

    public static final String TIME_MONTH_DAY_FORMAT = "MM.dd";
    public static final String DATE_YEAR_MONTH_FORMAT = "yyyy-MM";

    // 默认日期格式
    public static final String DATE_DEFAULT_FORMAT = "yyyy-MM-dd";


    public static final String DATETIME_HOUR_FORMAT = "yyyy-MM-dd HH";
    // 默认时间格式
    public static final String DATETIME_NOSECOND_FORMAT = "yyyy-MM-dd HH:mm";


    // 默认时间格式
    public static final String DATETIME_DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";


    public static final String DATE_FORMAT_YYYY = "yyyy";
    public static final String DATE_FORMAT_YYYYMM = "yyyyMM";
    public static final String DATE_FORMAT_YYYY_MM = "yyyy-MM";
    public static final String DATE_FORMAT_YYMMDD = "yyMMdd";
    public static final String DATE_FORMAT_YY_MM_DD = "yy-MM-dd";
    public static final String DATE_FORMAT_YYYYMMDD = "yyyyMMdd";
    public static final String DATE_FORMAT_YYYY_MM_DD = "yyyy-MM-dd";
    public static final String DATE_FORMAT_SLASH_YYYY_MM_DD = "yyyy/MM/dd";
    public static final String DATE_FORMAT_POINTYYYYMMDD = "yyyy.MM.dd";
    public static final String DATE_TIME_FORMAT_YYYY年MM月DD日 = "yyyy年MM月dd日";
    public static final String DATE_FORMAT_YYYYMMDDHHmm = "yyyyMMddHHmm";
    public static final String DATE_TIME_FORMAT_YYYYMMDD_HH_MI = "yyyyMMdd HH:mm";
    public static final String DATE_TIME_FORMAT_SLASH_YYYY_MM_DD_HH_MI = "yyyy/MM/dd HH:mm";
    public static final String DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI = "yyyy-MM-dd HH:mm";
    public static final String DATE_TIME_FORMAT_YYYYMMDDHHMISS = "yyyyMMddHHmmss";
    public static final String DATE_TIME_FORMAT_SLASH_YYYY_MM_DD_HH_MI_SS = "yyyy/MM/dd HH:mm:ss";
    public static final String DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_TIME_FORMAT_YYYYMMDDHHMISSSSS = "yyyyMMddHHmmssSSS";
    public static final String DATE_FORMAT_MMDDHHMI = "MM-dd HH:mm";
    public static final String DATE_FORMAT_MMM_D_YYYY_H_M_S_AM = "MMM d, yyyy h:m:s aa";
    public static final String[] parsePatterns = new String[]{"yyyy", "yyyyMM", "yyyy-MM", "yyMMdd", "yy-MM-dd", "yyyyMMdd", "yyyy-MM-dd", "yyyy/MM/dd", "yyyy.MM.dd", "yyyy年MM月dd日", "yyyyMMddHHmm", "yyyyMMdd HH:mm", "yyyy/MM/dd HH:mm", "yyyy-MM-dd HH:mm", "yyyyMMddHHmmss", "yyyy/MM/dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmmssSSS", "MM-dd HH:mm", "MMM d, yyyy h:m:s aa"};

    public static final DateTimeFormatter YMD_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");






    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static final String DATE_PATTERN_YYYY_MM_DD = "yyyy-MM-dd";

    public static final String DATE_PATTERN_YYYY_MM = "yyyy-MM";
    public static final String DATE_PATTERN_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";

    public static final String DATE_PATTERN_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

    public static final String DATE_PATTERN_YYYYMMDD_HHMMSS = "yyyyMMdd-HHmmss";
    public static final String DATE_PATTERN_YYYYMMDDHHMM = "yyyyMMddHHmm";

    public static final String DATE_PATTERN_YYYYMMDDHHMMSS_SSS = "yyyyMMddHHmmSSS";

    public static final String DATE_PARENT_YYMMDDHHMMSS = "yyMMddHHmmss";
    public static final String DATE_PARENT_YYMMDDHHMM = "yyMMddHHmm";
    public static final String DATE_PATTERN_YYYYMMDDHH = "yyyyMMddHH";

    public static final String DATE_PATTERN_YYMMDDHH = "yyMMddHH";
    public static final String DATE_PATTERN_YYYYMMDD = "yyyyMMdd";

    public static final String DATE_YYMMDDHHSSSSS = "yyMMddHH";

    public static final String TIME_PATTERN_HHMMSS = "HHmmSS";

    public static final String MONGTH_PATTERN_YYYYMM = "yyyyMM";

    public static final String DATE_PATTERN_YYMMDDHHMMSS = "yyMMddHHmmss";




    public static String getCnDateFormat(String dateStr){
        Date date = null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
            return new SimpleDateFormat("yyyy年MM月dd日").format(date);
        } catch (ParseException e) {
            log.error("formate date error :{}", e.getMessage());
        }
        return "";
    }




    public static final ThreadLocal<DateFormat> DATE_FORMATTER = new ThreadLocal<DateFormat>() {
        @Override
        protected DateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd");
        }
    };


}
